﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLCMS.Web.Wap.Code;
using NHibernate;
using DotNet.Common.NHibernateUtil;
using ZLCMS.Data.Model;

namespace ZLCMS.Web.Wap.Shop
{
    public partial class SubmitReturnApply_backup : MemberPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string orderNo = Request["no"];
            string productNo = Request["pno"];
            string skuNo = Request["sku"];
            using(ISession session = SessionFactoryHelper.CreateSession())
            {
                ShopOrderReturns rtRecord = null;
                if(!string.IsNullOrEmpty(orderNo))
                {
                    if (string.IsNullOrEmpty(productNo))
                    {
                        rtRecord = session.CreateQuery(" from ShopOrderReturns where OrderNo=:ono and MemberAccount=:member order by Id desc ")
                          .SetParameter("ono", orderNo).SetParameter("member", CurrentMemberAccount)
                          .SetMaxResults(1)
                          .UniqueResult<ShopOrderReturns>();
                    }
                    else
                    {
                        rtRecord = session.CreateQuery(" from ShopOrderReturns where OrderNo=:ono and ProductNo=:no and ProductSkuNo=:sku and MemberAccount=:member order by Id desc ")
                             .SetParameter("ono", orderNo).SetParameter("sku", skuNo)
                             .SetParameter("no", productNo).SetParameter("member", CurrentMemberAccount)
                             .SetMaxResults(1)
                             .UniqueResult<ShopOrderReturns>();
                    }
                }

                //未确认或未处理
                if (rtRecord != null && rtRecord.CancelStatus == "0" && (rtRecord.FinishStatus != "1" ))
                {
                    Response.Redirect("/wap/shop/ReturnsProgress.aspx?rid=" + rtRecord.Id);
                }
            }
        }
    }
}